//
//  Example3ViewController.m
//  Example3
//
//  Created by Benjamin Mort on 27/06/2012.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "Example3ViewController.h"

@implementation Example3ViewController

// Create accessor methods for variables
@synthesize name;
@synthesize password;
@synthesize sLabel;


-(IBAction) goAwayKeyboard: (id) sender 
{
    // Make the keyboard go away. 
    // First responder = controls used to edit the object
    // resign = make it go away.
    [sender resignFirstResponder];
}


-(IBAction) tapBackground: (id) sender
{
    // Remove regular keyboard - the one attached to name
    [name resignFirstResponder];
    
    // Remove password keyboard as well.
    [password resignFirstResponder];
}

// Slider method
-(IBAction) sliding: (id) sender
{
    // Make a local slider variable from the sender object (which will be the slider)
    UISlider *s = (UISlider *)sender;
    
    // Cast the value from the slider to an integer and store it in value.
    int value = (int) s.value;
    
    // Create string label from value.
    NSString *newLabel = [[NSString alloc]initWithFormat:@"%i", value];
    
    // Set the text of the label.
    sLabel.text = newLabel;
    
    // Free up memory
    [newLabel release];
}



- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [name release];
    [password release];
    [sLabel release];
    [super dealloc];
}

@end
